﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class guestbookback : System.Web.UI.Page
{
    public string SqlClass = "";
	public string gname,gtitle,gdate,gtel,gemail,gip,gaddress,gcontent,gcard;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserID"]==null)
		{
			Response.Write("<script>alert('你没有管理员权限，禁止访问！');history.back();</script>");
		}
		if (!Page.IsPostBack)
        {
            string id = Request.QueryString["id"];
            if (!string.IsNullOrEmpty(id))
            {
                HiddenField1.Value = Request.QueryString["id"];
				DataSet ds = Socut.Data.ExecuteDataSet("select * from web_guestbook where id=" + id);
                gname = ds.Tables[0].Rows[0][1].ToString();
				gtitle = ds.Tables[0].Rows[0][2].ToString();
				gaddress = ds.Tables[0].Rows[0][3].ToString();
				gemail = ds.Tables[0].Rows[0][4].ToString();
				gtel = ds.Tables[0].Rows[0][5].ToString();
				gip = ds.Tables[0].Rows[0][6].ToString();
				gcontent = ds.Tables[0].Rows[0][7].ToString();
				gdate = ds.Tables[0].Rows[0][8].ToString();
				gcard = ds.Tables[0].Rows[0]["gcard"].ToString();
				gback.Text = ds.Tables[0].Rows[0]["gback"].ToString();
				gischeck.SelectedValue = ds.Tables[0].Rows[0]["gcheck"].ToString();
				gisshow.SelectedValue = ds.Tables[0].Rows[0]["gisshow"].ToString();
            }
			else
			{
    			Response.Write("<script>alert('操作错误');history.back();</script>");
				
            }
			
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
	if (!string.IsNullOrEmpty(HiddenField1.Value))//回复
            {
                try
                {
                    Socut.Data.ExecuteNonQuery("update [web_guestbook] set gisshow='" + gisshow.SelectedValue + "',gcheck='" + gischeck.SelectedValue + "',gback='" + gback.Text +"' where id=" + HiddenField1.Value);
                    Response.Write("<script>alert('恭喜，留言操作成功！');location.href='guestbook.aspx';</script>");
					Response.End();
                }
                catch (Exception Err)
                {
                    Response.Write("<script>alert('操作错误');history.back();</script>");
					Response.End();
                }
            }
            else//错误
            {

                Response.Write("<script>alert('操作错误2');history.back();</script>");
					Response.End();


            }
    }
	
	

}
